#ifndef SIMUBOARD_BOARDVIEW_HPP
#define SIMUBOARD_BOARDVIEW_HPP
#include <vector>
#include <GUI/Widgets/LEDWidget.hpp>
#include <GUI/Widgets/FanWidget.hpp>
#include <GUI/Widgets/TemperatureWidget.hpp>
#include <GUI/Widgets/TimeWidget.hpp>
#include <GUI/Widgets/CurtainWidget.hpp>
#include <GUI/Widgets/SwitchWidget.hpp>
#include <GUI/Theme.hpp>

class Fl_Slider;
class ValueSlider;
class CardGroup;
class Fl_Window;

class BoardView
{
public:
    BoardView(int width, int height, const char* title);
    ~BoardView();

    void update_states(); // 现在同时更新风扇/时间/温度/窗帘
    void show();

    // 供回调访问
    TemperatureWidget* temp_widget_ptr() { return temp_widget; }
    TimeWidget* time_widget_ptr() { return time_widget; }

    void apply_theme_for_hour(unsigned char hour);

private:
    Fl_Window* main_window;
    std::vector<CardGroup*> card_groups; // 卡片容器集合，统一应用主题
    std::vector<LEDWidget*> led_widgets;
    std::vector<SwitchWidget*> switch_widgets; // 每个LED下方的开关
    FanWidget* fan_widget = nullptr;
    CardGroup* fan_group_ = nullptr; // 风扇卡片组，用于更新标题
    CurtainWidget* curtain_widget = nullptr;
    TemperatureWidget* temp_widget = nullptr;
    TimeWidget* time_widget = nullptr;
    ValueSlider* time_slider = nullptr;

    GUI::Theme current_theme_ = GUI::light_theme();
};

#endif //SIMUBOARD_BOARDVIEW_HPP
